package com.zenithmind.common.result;

import org.springframework.stereotype.Component;

/**
 * 默认结果构建器实现
 * 遵循单一职责原则：专门负责构建Result对象
 * 遵循里氏替换原则：可以替换ResultBuilder接口的任何实现
 * 
 * @param <T> 数据类型
 */
@Component
public class DefaultResultBuilder<T> implements ResultBuilder<T> {
    
    @Override
    public Result<T> buildSuccess() {
        return Result.Builder.success();
    }
    
    @Override
    public Result<T> buildSuccess(T data) {
        return Result.Builder.success(data);
    }
    
    @Override
    public Result<T> buildSuccess(String message, T data) {
        return Result.Builder.success(message, data);
    }
    
    @Override
    public Result<T> buildFail(ResultCode resultCode) {
        return Result.Builder.fail(resultCode);
    }
    
    @Override
    public Result<T> buildFail(ResultCode resultCode, String message) {
        return Result.Builder.fail(resultCode, message);
    }
    
    @Override
    public Result<T> buildFail(Integer code, String message, T data) {
        return Result.Builder.fail(code, message, data);
    }
}
